This set of SQL files is designed to change the [DocumentUri] and the [UriHash] values on all the records in the following tables: [Preview_Configuration].[dbo].[ProcessedDocuments], 
[Preview_Configuration].[dbo].[ProcessedDocumentsStatistics] and [Preview_Cache].[dbo].[DocumentContainer], when a migration from Connector Framework 3.1 to Connector Framework 4.0 is performed.

1.	Open Microsoft SQL Server Management Studio as Administrator.

2.	UpdateExtensionAndUriHashProcessedDocuments. The script changes the [DocumentUri] and [UriHash] cells. The extensions of all the records will be changed from their default values (e.g. doc, docx, pdf) to "SPW".
	The UriHash will be computed accordingly. 
	
	-Open UpdateExtensionAndUriHashProcessedDocuments.sql from the following location: "Unpack Destination Folder"\Tools\PreviewCacheMigrationScripts\
	The records are updated in batches of a given value, value that is configurable. The default batch size is 10000 records. In case the value needs to be changed, replace the default value in the following line: "SET @BatchSize = 10000; -- keep below 10000 to be safe"	
	In case more restrictions are needed(e.g. ContentSourceId is equal to a given value, or in a set of values), the following line should be changed: "SELECT TOP (@BatchSize) DocumentUri FROM ProcessedDocuments where DocumentUri LIKE 'spworks%' AND DocumentUri LIKE '%/data.%?%' AND NOT DocumentUri LIKE '%/data.SPW?%'".	
	
	-Press "Execute" ("F5"). The table contents will be displayed in the bottom view. Check that the file extensions in the [DocumentUri] columns have been changed to "SPW".

3.	UpdateExtensionAndUriHashProcessedDocumentsStatistics. The script changes the [DocumentUri] and [UriHash] cells. The extensions of all the records will be changed from their default values (e.g. doc, docx, pdf) to "SPW".
	The UriHash will be computed accordingly.
	
	-Open UpdateExtensionAndUriHashProcessedDocumentsStatistics.sql from the following location: "Unpack Destination Folder"\Tools\PreviewCacheMigrationScripts\
	The records are updated in batches of a given value, value that is configurable. The default batch size is 10000 records. In case the value needs to be changed, replace the default value in the following line: "SET @BatchSize = 10000; -- keep below 10000 to be safe"
	In case more restrictions are needed, the following line should be changed: "SELECT TOP (@BatchSize) DocumentUri FROM ProcessedDocuments where DocumentUri LIKE 'spworks%' AND DocumentUri LIKE '%/data.%?%' AND NOT DocumentUri LIKE '%/data.SPW?%'".	
	
	-Press "Execute" ("F5"). The table contents will be displayed in the bottom view. Check that the file extensions in the [DocumentUri] columns have been changed to "SPW".

4.	UpdateExtensionAndUriHashDocumentContainer. The script changes the [DocumentUri] cells. The extensions of all the records will be changed from their default values (e.g. doc, docx, pdf) to "SPW".
	The UriHash will be computed automatically.	
	
	-Open UpdateExtensionAndUriHashDocumentContainer.sql from the following location: "Unpack Destination Folder"\Tools\PreviewCacheMigrationScripts\
	The records are updated in batches of a given value, value that is configurable. The default batch size is 10000 records. In case the value needs to be changed, replace the default value in the following line: "SET @BatchSize = 10000; -- keep below 10000 to be safe"	
	In case more restrictions are needed, the following line should be changed: "SELECT TOP (@BatchSize) DocumentUri FROM ProcessedDocuments where DocumentUri LIKE 'spworks%' AND DocumentUri LIKE '%/data.%?%' AND NOT DocumentUri LIKE '%/data.SPW?%'".	
	
	-Change the following line: "use Preview_Cache -- please make sure to update the table name" to reflect the name of the current database (in case there are more than one [Preview_Cache] databases, add the coresponding number at the end of the database name).
	
	-Press "Execute" ("F5"). The table contents will be displayed in the bottom view. Check that the file extensions in the [DocumentUri] columns have been changed to "SPW".
	
5.	Check that the previews are still available.